home *** CD-ROM | disk | FTP | other *** search
/ Linux Cubed Series 3: Developer Tools / Linux Cubed Series 3 - Developer Tools.iso / devel / make / icmake-6.000 / icmake-6 / icmake / examples / tolower < prev   
Encoding:
Text File  |  1994-02-08  |  2.1 KB  |  75 lines

  1. #!/usr/local/bin/icmake -qi
  2.  
  3. /*
  4.     tolower: Icmake script to rename files to lower case. 
  5.     Use as follows.
  6.     
  7.     (1) Place this file in a given directory, e.g., $HOME/im.
  8.     (2) To rename all *.C in a directory to lowercase, try this (assuming
  9.         that the tcsh is used)
  10.         icmake -q ~/im/tolower -- *.C
  11.     (3) Alternatively, try the following tcsh alias (e.g., in your .tcshrc):
  12.         alias tolower 'icmake -q ~/im/tolower -- \!*'
  13.         (the quotes are needed here.)
  14.         then do:
  15.         tolower *.C
  16.     (4) Or another: make a shell script 'tolower' in your $HOME/bin 
  17.     directory, containing:
  18.         #!/bin/sh
  19.         icmake -q $HOME/im/tolower -- $*
  20.     Make the shell script executable, with "chmod +x tolower".
  21.     (5) Yet another method, which is preferred, is the following:
  22.         You can use this script as a literal executable, by renaming it to 
  23.         an extension-less file in your local bin directory:
  24.             mv <thisfile> ~/bin/tolower
  25.         Then, make it executable:
  26.             chmod +x ~/bin/tolower
  27.         Finally, add the following string as the first line to this file:
  28.             #!/usr/local/bin/icmake -qi
  29.         This line may actually be at the top of this file, check there.
  30.         This will cause the command "tolower" to start Icmake, with 
  31.     "-qi tolower" as arguments. Make sure that the /usr/local/bin/icmake
  32.     part of the text points to your icmake program; e.g., if you have 
  33.     icmake in /usr/bin, then that part should be /usr/bin/icmake.
  34. */
  35.  
  36. #define VERSION "1.01"
  37.  
  38. void process (string file)
  39. {
  40.     string
  41.         lower;
  42.         
  43.     lower = strlwr (file);
  44.     if (lower != file)
  45.         if (exec (P_NOCHECK, "mv", file, lower))
  46.             printf ("tolower: can't rename ", file, " to ", lower, "\n");
  47. }
  48.  
  49. void main (int argc, list argv)
  50. {
  51.     int
  52.         i;
  53.         
  54.     echo (0);
  55.         
  56.     if (argc < 2)
  57.     {
  58.         printf ("\n"
  59.             "ICCE Filecase Converter Version ", VERSION, "\n"
  60.             "Copyright (c) ICCE 1993.  All rights reserved.\n"
  61.             "\n"
  62.             "Usage: tolower file(s)\n"
  63.             "Where: file(s) are the filenames to be renamed to their "
  64.                             "lower case names\n"
  65.         "\n"
  66.         );
  67.     exit (1);
  68.     }
  69.     
  70.     for (i = 1; i < sizeof (argv); i++)
  71.         process (element (i, argv));
  72.     exit (0);
  73. }
  74.  
  75.